package com.example;

import org.greenrobot.greendao.generator.DaoGenerator;
import org.greenrobot.greendao.generator.Entity;
import org.greenrobot.greendao.generator.Schema;

public class GeneratorMain {
    public static void main(String[] args) {
        //版本号 存放entry的文件夹
        Schema schema = new Schema(1, "com.example.ice.fittime.entry");
        //存放dao的文件夹
        schema.setDefaultJavaPackageDao("com.example.ice.fittime.dao");

//        //Bean类
//        Entity entity = schema.addEntity("Students");
//        //entity.addIdProperty().autoincrement();//id
//        entity.addFloatProperty("num").primaryKey();
//        entity.addStringProperty("name");
//        entity.addIntProperty("age");

        //Pu的首页
     //   addArticleBanner(schema);
        addExperienceShare(schema);
     //   addTopic(schema);
     //   createBanners(schema);
     //   createUserActivity(schema);
        DaoGenerator generator;
        try {
            generator = new DaoGenerator();
            generator.generateAll(schema, "app\\src\\main\\java");
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void addArticleBanner(Schema schema) {
        Entity entity = schema.addEntity("ArticleBanner");
        entity.addIntProperty("id");
        entity.addStringProperty("title");
        entity.addStringProperty("image_url");
        entity.addStringProperty("target");
    }

    public static void addExperienceShare(Schema schema) {
        Entity experienceShare = schema.addEntity("ExperienceShare");
        experienceShare.addLongProperty("shareId").primaryKey();
        experienceShare.addLongProperty("comment_count");
        experienceShare.addLongProperty("collection_count");
        experienceShare.addLongProperty("view_count");
        experienceShare.addLongProperty("praise_count");
        experienceShare.addStringProperty("title");
        experienceShare.addStringProperty("description");
        experienceShare.addStringProperty("image_url");
        experienceShare.addStringProperty("category");

        Entity user = schema.addEntity("User");
        user.addLongProperty("userId").primaryKey();
        user.addStringProperty("name");
        user.addStringProperty("avatar_url");
//        Property userProperty = experienceShare.addLongProperty("userId").getProperty();
//        // 第一个参数为目标实体类，第二个参数为此表中的外键属性
//        experienceShare.addToOne(user, userProperty);

    }

    public static void addTopic(Schema schema) {
        Entity topic = schema.addEntity("Topic");
        topic.addLongProperty("topic_id").primaryKey();
        topic.addLongProperty("article_id");
        topic.addLongProperty("position");
        topic.addStringProperty("title");

        Entity article = schema.addEntity("Article");
        article.addLongProperty("article_id").primaryKey();
        article.addLongProperty("comment_count");
        article.addLongProperty("collection_count");
        article.addLongProperty("view_count");
        article.addLongProperty("praise_count");
        article.addStringProperty("title");
        article.addStringProperty("description");
        article.addStringProperty("image_url");
        article.addStringProperty("category");
    }
    public  static void createBanners(Schema schema){
        Entity entity = schema.addEntity("Banners");
        entity.addStringProperty("id").primaryKey().notNull();
        entity.addStringProperty("title").notNull();
        entity.addStringProperty("image_url").notNull();
        entity.addStringProperty("type").notNull();
        entity.addStringProperty("target").notNull();
        entity.addStringProperty("create_time");
        entity.addStringProperty("update_time");

    }
    public static void createUserActivity(Schema schema){

        Entity userDetail = schema.addEntity("UserDetail");
        userDetail.addStringProperty("user_id").primaryKey().notNull();
        userDetail.addStringProperty("name");
        userDetail.addStringProperty("create_time");
        userDetail.addStringProperty("update_time");
        userDetail.addStringProperty("gender");
        userDetail.addStringProperty("description");
        userDetail.addStringProperty("avatar");
        userDetail.addStringProperty("birthday");
        userDetail.addStringProperty("height");
        userDetail.addStringProperty("weight");
        userDetail.addStringProperty("location");
        userDetail.addStringProperty("is_verified");
        userDetail.addBooleanProperty("is_blocked");
        userDetail.addStringProperty("has_article_permission");
        userDetail.addStringProperty("is_pinned");
        userDetail.addStringProperty("is_selected");
        userDetail.addStringProperty("level");
        userDetail.addStringProperty("workout_level");
        userDetail.addStringProperty("workout_purpose");
        userDetail.addStringProperty("workout_frequency");
        userDetail.addStringProperty("badge");
        userDetail.addStringProperty("avatar_url");

        Entity stickerImage = schema.addEntity("StickerImage");
        stickerImage.addStringProperty("image_id").primaryKey();
        stickerImage.addStringProperty("content");
        stickerImage.addStringProperty("x");
        stickerImage.addStringProperty("y");
        stickerImage.addStringProperty("style");
        stickerImage.addStringProperty("type");

        Entity image = schema.addEntity("UserImage");
        image.addStringProperty("id").primaryKey();
        image.addStringProperty("create_time");
        image.addStringProperty("size");
        image.addStringProperty("height");
        image.addStringProperty("width");
        image.addStringProperty("url");

//        Property sticker = image.addStringProperty("sticker_s").getProperty();
//        image.addToMany(stickerImage,sticker,"sticker");


        Entity praiseUser = schema.addEntity("PraiseUser");
        praiseUser.addStringProperty("user_id").primaryKey();
        praiseUser.addStringProperty("name");
        praiseUser.addStringProperty("avatar_url");



        Entity commentUser = schema.addEntity("CommentUser");
        commentUser.addStringProperty("id").primaryKey().notNull();
        commentUser.addStringProperty("user_id");
        commentUser.addStringProperty("activity_id");
        commentUser.addStringProperty("reply_id");
        commentUser.addStringProperty("reply_user_id");
        commentUser.addStringProperty("content");
        commentUser.addStringProperty("create_time");
        commentUser.addStringProperty("update_time");
        commentUser.addStringProperty("link_id");
        commentUser.addStringProperty("reply_user_name");

//        Property user1 = commentUser.addStringProperty("user_s").getProperty();
//        commentUser.addToOne(userDetail,user1,"user");


        Entity userActivity = schema.addEntity("UserActivity");
        userActivity.addStringProperty("id").primaryKey().notNull();
        userActivity.addStringProperty("user_id");
        userActivity.addStringProperty("content");
        userActivity.addStringProperty("create_time");
        userActivity.addStringProperty("update_time");
        userActivity.addStringProperty("checkin_id");
        userActivity.addStringProperty("is_private");
        userActivity.addStringProperty("is_selected");
        userActivity.addStringProperty("weight");
        userActivity.addStringProperty("total_praise");
        userActivity.addStringProperty("total_comment");
        userActivity.addStringProperty("is_isolated");
        userActivity.addStringProperty("video_url");

//        Property user_s = userActivity.addStringProperty("user_s").getProperty();
//        userActivity.addToOne(userDetail,user_s,"user");
//
//        Property image_s = userActivity.addStringProperty("image_s").getProperty();
//        userActivity.addToOne(image,image_s,"image");
//
//        Property recent_praise_user_s = userActivity.addStringProperty("recent_praise_user_s").getProperty();
//        userActivity.addToMany(praiseUser,recent_praise_user_s,"recent_praise_user");
//
//        Property comment_s = userActivity.addStringProperty("comment_s").getProperty();
//        userActivity.addToMany(commentUser,comment_s,"comment");

    }


}
